数字图像处理实验一:图像信号的数字化 matlab 您所在的位置:网站首页 matlab 黑白反转 数字图像处理实验一:图像信号的数字化 matlab

数字图像处理实验一:图像信号的数字化 matlab

2023-07-10 17:53| 来源: 网络整理| 查看: 265

源程序:

I=imread('13.bmp');

figure;

imshow(I);

[M,N,Q]=size(I);

K=rgb2gray(I);

B=imresize(K,[50,50],'nearest');C=imresize(K,[100,100],'nearest');%用最近邻插值改变图片像素

D=imresize(K,[1000,1000],'nearest');

E=imresize(K,0.1,'nearest');%放大倍数为0.1倍

F=imresize(K,0.2,'nearest');%放大倍数为0.2倍

subplot(2,3,1);imshow(I);title('原图');

subplot(2,3,2);imshow(B);title('像素50*50');

subplot(2,3,3);imshow(C);title('像素100*100');

subplot(2,3,4);imshow(D);title('像素1000*1000');

subplot(2,3,5);imshow(E);title('原图像缩小为0.1倍');

subplot(2,3,6);imshow(F);title('原图像缩小为0.2倍');hold on;figure;

thresh=graythresh(K);%使用最大类间方差法获得一个合适的阈值

A1=histeq(K,32);A2=histeq(K,128);A3=histeq(K,256); %变换灰度图像,在K中返回具有32,128,256个离散灰度级的灰度图像

B1=im2bw(A1,thresh);B2=im2bw(A2,thresh);B3=im2bw(A3,thresh);%将灰度图像  转换为二进制图像。输出图像 BW 将输入图像中亮度值大于 thresh 的像素替换为值1 (白色),其他替换为值0(黑色)

subplot(2,3,1);imshow(K,[0,31]);title('灰度级为32的图像');

subplot(2,3,2);imshow(K,[0,127]);title('灰度级为128的图像');

subplot(2,3,3);imshow(K,[0,255]);title('灰度级为256的图像');

subplot(2,3,4);imshow(B1,[]);title('灰度级4的二值化图');

subplot(2,3,5);imshow(B2,[]);title('灰度级32的二值化图');

subplot(2,3,6);imshow(B3,[]);title('灰度级256的二值化图');



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有